<?php ob_start(); ?> 
<?php header ('Content-type: text/xml; charset=utf-8'); ?>     

<?php include "constants.inc" ?>

<?php include "classes.inc" ?>

<?php session_start(); ?>

<?php

function storePlayerName($playerName, $row) {

	if ( isset($_SESSION['user']) && isset($playerName) && isset($_SESSION['players']) && isset($row) ) {

        $user = $_SESSION['user'];

        $players = $_SESSION['players'];

        $player = $players[$row-1];



        if (empty($player->player_key)) {

        	$player->player_name = $playerName;

            $players[$row-1] = $player;

	        $_SESSION['players'] = $players;

	        return '1';

        } else {

            $connect = mysql_connect(DB_SERVER, DB_USER, DB_PWD);

			mysql_select_db(DB_CATALOG);

			$result = mysql_query("select nom_prenom from playernew where matricule = ".$player->player_key);

        	$record = mysql_fetch_assoc($result);

        	if (strnatcasecmp($record['nom_prenom'], $playerName) == 0) {

            	return '1';

            }

            return '2';

        }

    }

    return '0';

}

?>

<response>

  <method>storePlayerName</method>

  <result><?php

    echo storePlayerName($_GET['playerName'], $_GET['row'])?></result>

</response>